<?php
 If (!IsSet ($reentrance))
  {
   Session_Start () ;
   Include ("../../include/garennes.cfg") ;
   Include ("../../include/init.php") ;
   Include ("../include/config.inc") ;
   verif_droits ($droit_courant, $_SESSION ["code"]) ;
  }

 $id_service_prof = var_courante ("id_service_prof", 0, 0) ;
 $periode = var_courante ("periode", 0, null) ;
 $millesime = millesime (0) ;
 
 $param_theme = parametres_theme (themeparsession ($_SESSION ["code"])) ;
 $rep_themes = "../../images/themes/" ;
 Include ($rep_themes.$param_theme ["nom_repertoire"]."/".$param_theme ["fichier_config"]) ;
 
 $affichage_notes = 0 ;
 
 $nbr_periode = nombre_periode ($id_classe) ;
 $nomperiode = StrToUpper (nom_periode ($id_classe)) ;
 If (!IsSet ($periode)) { $periode = 1 ; } ElseIf ($periode > $nbr_periode) { $periode = $nbr_periode ; }
 
 Echo "<HTML><HEAD>" ;
 entete_html ("Garennes", "", 1) ;
 Echo styles ("none", "none", "none", $theme [0][32], "none") ;
 Echo "</HEAD>" ;
 
 // Gestion
 $resultat = SQL_commande ("SELECT * FROM gestion ORDER BY millesime DESC LIMIT 1", $id_sql) ;
 $gestion = SQL_tableau_associatif ($resultat, "") ;

 // Discipline
 $serv_p = SQL_commande ("SELECT discipline,id_service_prof FROM services_prof WHERE id_service_prof='".$id_service_prof."' LIMIT 1", $id_sql) ;
 $sp = SQL_ligne_suivante ($serv_p) ;
 $discipline = $sp [0] ;
 $id_sp = $sp [1] ;
 
 // Liste des eleves
 $serv_prof = SQL_commande ("SELECT * FROM services_prof WHERE id_service_prof='".$id_service_prof."' AND millesime='".$millesime."' LIMIT 1", $id_sql) ;
 $sp = SQL_tableau_associatif ($serv_prof, "") ; 
 $table = eleves_par_service_classe ($id_service_prof) ;
 
 Echo "<BODY BACKGROUND=\"".$rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][10]."\" onContextMenu=\"return false\">" ;
 Echo "<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLSPACING=\"0\" CELLPADDING=\"0\">" ;
 Echo "<TR><TD ALIGN=\"CENTER\"><FONT SIZE=\"+1\" COLOR=\"".$theme [0][38]."\">" ;
 If ($theme [0][39] == 1) { Echo "<B>" ; }
 If ($theme [0][40] == 1) { Echo "<I>" ; }
 If ($theme [2][1] == 0)
  {
   Echo "Appr&eacute;ciations&nbsp;et&nbsp;moyennes&nbsp;sur&nbsp;".$gestion ["max"].".&nbsp;".$nomperiode."&nbsp;".$periode."<BR>".nom_disc_long_parid ($discipline) ;
  }
 Else
  {
   Echo nom_disc_long_parid ($discipline) ;
   $titre_fenetre = "Appr&eacute;ciations&nbsp;et&nbsp;moyennes&nbsp;sur&nbsp;".$gestion ["max"].".&nbsp;".$nomperiode."&nbsp;".$periode ;
  }
 If ($theme [0][40] == 1) { Echo "</I>" ; }
 If ($theme [0][39] == 1) { Echo "</B>" ; }
 Echo "</FONT></TD></TR></TABLE>" ;

 // Icones
 Echo "<TABLE BORDER=\"0\" ALIGN=\"CENTER\" CELLSPACING=\"0\" CELLPADDING=\"0\">" ;
 Echo "<TR><TD ALIGN=\"RIGHT\" vALIGN=\"TOP\"><BR><BR>" ;
 Echo "<A HREF=\"javascript:window.print();\"><IMG SRC=\"".$rep_themes.$param_theme ["nom_repertoire"]."/".$theme [9][8]."\" BORDER=\"0\" TITLE=\"Imprimer la page.\"></A>" ;
 Echo "&nbsp;&nbsp;</TD>" ;
 Echo "<TD>" ;
 
 Include ("../include/debut_theme.inc") ;
 
 Echo "<TABLE BORDER=\"0\" BGCOLOR=\"".$theme [0][3]."\" CELLSPACING=\"0\" CELLPADDING=\"0\" WIDTH=\"100%\">" ;
 
 // Construction de la requete
 $requete = "SELECT * FROM eleves WHERE " ;
 For ($i = 1 ; $i <= $table [0] ; $i++)
  {
   $requete .= "id_eleve='".$table [$i]."'" ;
   If ($i < $table [0]) { $requete .= " OR " ; }
  }
 $requete .= " ORDER BY nom,prenoms" ;
 $eleve = SQL_commande ($requete, $id_sql) ;
 
 For ($i = 0 ; $i < SQL_nbr_lignes ($eleve) ; $i++)
  {
   // Boucle d'affichage des appreciations
   $ligne = SQL_tableau_associatif ($eleve, "") ;
   If (StrPos ($ligne ["prenoms"], " "))
    {
     $prenom = SubStr ($ligne ["prenoms"], 0, StrPos ($ligne ["prenoms"], " ")) ;
    }
   Else { $prenom = $ligne ["prenoms"] ; }
   Echo "<TR BGCOLOR=\"".$theme [10][$i%$theme [10][0]+1]."\">" ;
   // Compteur d'eleve+ligne verticale
   Echo "<TD VALIGN=\"MIDDLE\" ALIGN=\"RIGHT\" ROWSPAN=\"3\">&nbsp;".($i+1)."&nbsp;</TD>" ;
   Echo "<TD BGCOLOR=\"".$theme [0][6]."\" ROWSPAN=\"3\" WIDTH=\"2\"></TD>" ;
   
   // Affichage nom+moyenne+notes (eventuel)
   Echo "<TD ALIGN=\"LEFT\">&nbsp;<B>".$ligne ["nom"]."</B>&nbsp;" ;
   Echo "<I>".SubStr ($prenom, 0, 1).SubStr ($prenom, 1, StrLen ($prenom)-1)."</I></TD>" ;
   Echo "<TD ALIGN=\"LEFT\">&nbsp;<B>Moyenne&nbsp;:&nbsp;" ;
   Echo Str_Replace (".", ",", moyenne_el ($ligne ["id_eleve"], $id_classe, $periode, $sp ["discipline"], $sp ["service_classe"], $id_sp, 1, 0)) ;
   Echo "&nbsp;</TD>" ;
   If ($affichage_notes == 1)
    {
     Echo "<TD ALIGN=\"LEFT\">&nbsp;Notes&nbsp;:&nbsp;" ;
     $notes = notes_el_disc ($ligne ["id_eleve"], $id_service_prof, $periode) ;
     For ($j = 0 ; $j < $notes [0][0] ; $j++)
      {
       Echo Str_Replace (".", ",", $notes [$j][1])."/".Str_Replace (".", ",", $notes [$j][2]) ;
       If ($j < $notes [0][0]-1) { Echo "-" ; }
      }
     Echo "</TD>" ;
    }
   Echo "</TR>" ;
   
   // Trait de separation
   Echo "<TR BGCOLOR=\"".$theme [0][7]."\" HEIGHT=\"2\"><TD COLSPAN=\"".(4+$affichage_notes)."\"></TD></TR>" ;
   
   // Affichage appreciations
   Echo "<TR BGCOLOR=\"".$theme [10][$i%$theme [10][0]+1]."\">" ;
   Echo "<TD COLSPAN=\"".(2+$affichage_notes)."\">" ;
   Echo "<I><FONT SIZE=\"-1\">" ;
   Echo formatage (appreciation ($ligne ["id_eleve"], $sp ["professeur"], $discipline, $sp ["id_service_prof"], $periode), 70) ;
   Echo "</FONT></I></TD>" ;
   Echo "</TR>" ;

   // Affichage ligne horizontale
   If ($i < SQL_nbr_lignes ($eleve)-1) { Echo "<TR BGCOLOR=\"".$theme [0][8]."\" HEIGHT=\"2\"><TD COLSPAN=\"".(4+$affichage_notes)."\"></TD></TR>" ; }
   Echo "</TD>" ;
   Echo "</TR>" ;
  }
 Echo "</TABLE>" ;
 Include ("../include/fin_theme.inc") ;
 
 Echo "</TD></TR></TABLE>" ;
 Echo "</BODY></HTML>" ;
?>